package hanqi.mangement.Controller;

import hanqi.mangement.Service.studentservice;
import hanqi.mangement.entity.gradebro;
import hanqi.mangement.entity.student;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;

@RestController
@RequestMapping("student")
public class studentController {
    @Autowired
    private studentservice studentService;
    @GetMapping("/listAll")
    public List<student> listAll() {
        return studentService.listAll();
    }

    @GetMapping("/getById/{studentId}")
    public student getById(@PathVariable int studentId) {
        return studentService.getById(studentId);
    }

    @GetMapping("/getGrades/{studentId}")
    public List<gradebro> getGrades(@PathVariable int studentId) {
        return studentService.getGrades(studentId);
    }

    @PostMapping("/add")
    public String add(@RequestBody student student) {
        studentService.addStudent(student);
        return "数据插进来了喵(=^・ω・^=)ノ☆";
    }
}
